<%@ page import="java.util.jar.Attributes.Name"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="support.*,bean.*,java.util.*" %>
    
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Degree-discipline</title>
<link href="main.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
	// Get location from HTTP request
	Vector<Degree> degrees = (Vector<Degree>)session.getAttribute("degrees");
	Degree degree = null;
	if(degrees == null)
	{
		degrees = new Vector<Degree>();
		degree = new Degree();
		degrees.add(degree);
		session.setAttribute("degrees", degrees);
	}
	degree = degrees.lastElement();
	
	support s = new support();

	Vector universities = (Vector)application.getAttribute("universities");
	if(universities == null)
	{
		String path = config.getServletContext().getRealPath("universities.txt");
		universities = s.getUniversities(path);
		application.setAttribute("universities", universities);
	}
	
	int loc_id = degree.getLocation();
	
	String university_id = (String)request.getParameter("univ_id");
	String university = (String)request.getParameter("university");
	int univ_id;
	if (university_id != null && university == null){  // User choose a exist university
		univ_id = Integer.valueOf(university_id);
	}
	else {										       // User manually enter a university
		Vector univState = (Vector) ((Vector) universities.get(loc_id)).get(1);
		univState.add(university);
		univ_id = univState.size() - 1;
	}
	degree.setUniv(univ_id);
%>
<h1>Provide degrees - Choose discipline</h1>
<%
	// Get countries from text file
	Vector disciplines = (Vector)application.getAttribute("disciplines");
	if(disciplines == null)
	{
		String path = config.getServletContext().getRealPath("majors.txt");
		disciplines = s.getMajors(path);
		application.setAttribute("disciplines",disciplines);
	}
%>
<form name="form1" action="moredegree.jsp" method="post">
	<% for(int i=0;i<disciplines.size();i++){	%>
	<input type="radio" name="discipline_id" value="<%= i %>" <%= (i==0) ? "checked=\"yes\"" : "" %>> 
	<%= disciplines.get(i) %> <br />
	<%  } %>
	<br/>
	<h1>If not found, input your Major below:<h1>
	
	<input type="text" name="discipline" value=""><br/>
	Month: <input type="text" name="month" value="">
	Year: <input type="text" name="year" value=""><br/>
	GPA: <input type="text" name="gpa" value=""><br/>
	Title of degree:
	<select name = "title">
		<option value="bs">BS</option>
		<option value="ms">MS</option>
		<option value="phd">Phd</option>
	<select><br/>
	<input type="submit" value = "submit">
</form>	
</body>
</html>